package com.glls.lambda.demo5;

import com.glls.lambda.pojo.Student;
import org.junit.Test;

import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @date 2022/10/3
 * @desc  构造器引用
 */
public class TestConstructorRef {

    @Test
    public void test1(){
        Supplier<Student> supplier = ()-> {return  new Student();};

        Supplier<Student> supplier2 = Student::new;   // 无参构造的参数列表 和 Supplier 接口的抽象方法的参数列表一致

        Student student = supplier2.get();


    }

    @Test
    public void test2(){
        //Consumer<String> consumer = Student::new;
        //consumer.accept("赵怀真");
        //
        //Consumer<Integer> consumer2 = Student::new;
        //consumer2.accept(18);


        Function<Integer,Student> function = Student::new;

        Student student = function.apply(22);

        System.out.println(student);

        BiFunction<Integer,Integer,Student> biFunction = Student::new;



    }

}
